Monkey Documentation

The Android target

Android is Google's hugely popular cellphone and tablet OS.

You will need

  • The Android SDK. You only need the "SDK Tools" version, not the "Eclipse+ADT Plugin" one.
  • The Java SE JDK. On Windows, make sure to grab the 32bit version even if you're running a 64bit OS.
  • On Windows and MacOS, you will also need ANT.

Getting started

The ANDROID_PATH (Windows/MacOS), JDK_PATH (Windows) and ANT_PATH (Windows/MacOS) vars in your Trans config file must be correctly set to use the android target.

The Android download is just a 'setup' app - after installation you will prompted to run the SDK manager, which you will need to do to install the actual android SDKs. Make sure to install at least "Android SDK Platform-tools" and "Android 3.2 (API 13) SDK Platform".

To run apps on real hardware on MacOS, you should be able to just 'plug and play'. Make sure to enable 'USB debugging' on the device first though.

To run apps on real hardware on Windows, you will need to install USB drivers. USB drivers from device manufacturers are generally the preferred solution, although they often tend to come bundled with nasty bloated 'virtual desktop' apps. With a bit of googling, you may be able to track down a plain USB driver for your device.

Signing apps

Before you can publish apps or add in app purchases, apps must be 'signed'.

The first step in signing an app is to generate a key for it. The tools to do this are in the Java JDK, so this must be in your PATH. To generate a key, use something like:

keytool -genkey -v -keystore release-key.keystore -alias release-key-alias -keyalg RSA -keysize 2048 -validity 10000

If you execute this from a dos prompt, you will be prompted for various author information and passwords. Once complete, you will be left with a key file called 'release-key.keystore'. This is your app's key, and you should not lose it as you will need it every time you update your app.

If you selected the password 'password' when generating the key, then the key can be used 'as is' - simply copy it to your app's main source directory and set the #ANDROID_SIGN_APP app config setting to True to enable signing. Building your app will then produce a signed app.

If you used a different password, or different key file name/location, you will also need to modify some or all of the following app config settings (default shown):

#ANDROID_KEY_STORE="../../release-key.keystore"
#ANDROID_KEY_ALIAS="release-key-alias"
#ANDROID_KEY_STORE_PASSWORD="password"
#ANDROID_KEY_ALIAS_PASSWORD="password"

Publishing on GooglePlay

To publish apps on GooglePlay, you will need to create developer account at https://play.google.com/apps/publish/

Once you have a developer account, you will be able to upload your app, add in app purchases and start publishing.

Your app will need to have a unique 'package name'. This can be done via the #ANDROID_APP_PACKAGE app config setting, which should be set to something like "com.mycompany.mygame".

Testing in-app purchases

In-app purchases can be added to your app using the MonkeyStore class.

Testing IAP is a bit tricky. The general idea on both Android/iOS is that you create 'test' accounts to test with, and add these test accounts to the GooglePlay Dev Console and/or iTunes Connect. Test accounts are generally just email address/password combos, although on Android you'll have to provide more details the first time you use the test account.

  • On Android, your app must be signed and a version uploaded (but not necessarily 'published') to your Google Play developer account.
  • On Android devices, you can create a new user for your test account (and it doesn't have to be the 'primary' user) but you will need to 'always allow' USB debugging for the primary user before using the test user. Also, you may need to uninstall old versions of your app from the primary user before testing.
  • On Android, repeated use of a test account sometimes appears to trigger some kind of 'fraudulent transaction' logic, after which time you app will report 'cannot process transaction' when you attempt to buy something and you'll receive a 'transaction cancelled' email. Solution: wait until things return to normal, or create a new test account and use that instead.
There's a bananas/mak/iaptest demo in the release, but it wont work 'as-is' - you'll need to add a keystore file for android and change the BundleID for ios, and change the CONSUMABLES and NON_CONSUMABLES arrays to match your product ids.